/**
 * Created by Elsa on 2017/8/30.
 */
layui.define(['form', 'layedit', 'laydate','jquery'], function(exports){
    var form = layui.form(),
        $ = layui.jquery,
        layer = layui.layer,
        layedit = layui.layedit,
        laydate = layui.laydate;

    var inspnum = getQueryString("inspnum");

    form.render();

    form.on('select(type1)', function(data){
        if(data.value == '通过'||data.value == '不通过'){
            $('input[name="rq2"]').attr("value",getNowFormatDate());
            form.render();
        }else{

        }
    });

    form.on('select(type2)', function(data){
        if(data.value == '报检单填写有误'){
            $('#confrimlabel').html("");
            $('input[name="confirmtime"]').hide();
            $('input[name="rq3"]').attr("value",getNowFormatDate());
            form.render();
        } else if(data.value == '报检单填写无误'){
            $('#confrimlabel').html("确认检验时间");
            $('input[name="confirmtime"]').show();
            $('input[name="rq3"]').attr("value",getNowFormatDate());
            form.render();
        }else{

        }
    });

    form.on('select(type3)', function(data){
        if(data.value == '通过'){
            $('#rectnumlabel').html("");
            $('input[name="rectnum"]').hide();
            $('#norect').show();
            $('#rect').hide();
            $('#rectt').hide();
            $('input[name="rq4"]').attr("value",getNowFormatDate());
            form.render();
        } else if(data.value == '需整改'){
            $('#rectnumlabel').html("整改编号");
            $('input[name="rectnum"]').show();
            $('#norect').hide();
            $('#rect').show();
            $('input[name="rq4"]').attr("value",getNowFormatDate());
            form.render();
        }else{

        }
    });

    //自定义验证规则
    form.verify({
        title: function(value) {
            if(value.length < 5) {
                return '标题至少得5个字符啊';
            }
        },
        pass: [/(.+){6,12}$/, '密码必须6到12位'],
        content: function(value) {
            layedit.sync(editIndex);
        }
    });

    exports('ConstDetailsCheck', {}); //注意，这里是模块输出的核心，模块名必须和use时的模块名一致
});